package com.zhm.demo;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import com.zhm.demo.mysql.sit.mapper.SitFeishuIndexMapper;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.List;
import java.util.Map;

@EnableDynamicTp
//@EnableConfigurationProperties
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        MybatisPlusAutoConfiguration.class,
//        PageHelperAutoConfiguration.class,
        RedisAutoConfiguration.class,
        ElasticsearchDataAutoConfiguration.class,
        ElasticsearchRepositoriesAutoConfiguration.class
}, scanBasePackages = "com.zhm.demo.mysql.sit")
public class MysqlApplication {
    public static void main(String[] args) {
        // 动态禁用 Sentinel
        System.setProperty("spring.cloud.sentinel.enabled", "false");
//        System.setProperty("spring.dynamic.tp.enabled", "false");
        SpringApplication application = new SpringApplication(MysqlApplication.class);
        // 设置 Web 应用类型为 NONE，不启动 Web 服务
        application.setWebApplicationType(WebApplicationType.NONE);
        ConfigurableApplicationContext context = application.run(args);
        SitFeishuIndexMapper sitFeishuIndexMapper = context.getBean(SitFeishuIndexMapper.class);
        sitFeishuIndexMapper.createTable("zhm", Map.of("id", "varchar(20)", "name", "varchar(20)"));
        sitFeishuIndexMapper.insertData("zhm", "1", Map.of("id", "1", "name", "zhm"));
        List<Map<String, Object>> maps = sitFeishuIndexMapper.listData("zhm");
        System.out.println(maps);


    }

}
